import os
from project1 import DOC_Process,IMAGE_Process
from win32com import client as wc
import fnmatch
import PDF_Process
import XLS_Process

# 韩泽旭
file_path = "D:/课题/data/wzj"
result_path = "D:/课题/data/result"
# 闫佳琪
file_path = "./wzj"
result_path="./PDF"
# 马妍
# path=""
# result_path=""

if __name__ == '__main__':
    wordapp = wc.Dispatch('Word.Application')
    image_time = 0

    list = os.listdir(file_path)
    num = 0
    try:
        for i in list:
            num = num + 1
            print(str(num) + " " + os.path.basename(i))
            type = os.path.splitext(i)[1]
            if type == ".docx" or type == ".doc":
                DOC_Process.fun(os.path.basename(i), wordapp)
            elif type == ".pdf":
                result_path = "./PDF"
                pdf_name = os.path.basename(i).split('.')[0]
                # print(pdf_name)
                PDF_Process.fun(pdf_name)
                continue
            elif type == ".jpg" or type == ".png" or type == ".jpeg" or type == ".JPG" or type == ".PNG" or type == ".JPEG":
                image_time = image_time + 1
                IMAGE_Process.fun(os.path.basename(i), image_time)
            elif type == ".xls" or type == ".xlsx":
                # print(os.path.basename(i))
                result_path = './XLS'
                if (type == '.xlsx'):
                    XLS_Process.fun(os.path.basename(i))
                if (type == '.xls'):
                    XLS_Process.fun2(os.path.basename(i))
                continue
            # elif type==".zip" or type==".rar":
    finally:
        wordapp.Quit()
